import axios from "axios";
import showMessage from "@/utils/showMessage";

const ins = axios.create();
ins.interceptors.response.use(function (resp) {

    if (resp.data.code !== 0) {
        let msg = resp.data.msg;
        if(typeof resp.data === "string") {
            msg = JSON.parse(resp.data).msg;
        }        
        showMessage({
            content: msg,
            type: "warn"
        })
        return;
    }

    return resp.data.data;
})

export default ins;